from stack.service.stack import site
from stack.service.stack import StackConfig
from stack.service.stack import Option
from web.models import Student


class StudentConfig(StackConfig):
    #展示的字段
    # list_display = [StackConfig.display_checkbox,'id','name','department',StackConfig.display_edit,StackConfig.display_edit_del_display,StackConfig.display_del]
    order_by = ['-id']   #排序列表
    def muti_init(self,request):  #添加批量操作的方法
        pass
    muti_init.text='批量初始化'
    action_list = [muti_init,StackConfig.multi_delete]  #批量操作
    search_list = ['name','teacher__name']  #模糊搜索
    filter_list = [
        # Option('gender',is_choice=True,text_func=lambda x:x[1]),
        Option('gender', is_choice=True,),#  不用text_func 的情况
        # Option('department',text_func=lambda x:x.name),
        Option('department',),#不用text_func 的情况  forienkey
        # Option('teacher',text_func=lambda x:x.name),  #
        Option('teacher',is_multi=True),# 不用text_func   的情况   manytomany
                   ]
site.register(Student,StudentConfig)
